<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>模型评估与部署 - AI 中心</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .nav-pills .nav-link.active {
            background-color: #0d6efd;
        }
        .metric-card {
            transition: transform 0.2s;
        }
        .metric-card:hover {
            transform: translateY(-5px);
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">模型评估与部署</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="../index.html">返回 AI 中心</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <!-- 左侧导航 -->
            <div class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
                <div class="position-sticky pt-3">
                    <ul class="nav flex-column nav-pills">
                        <li class="nav-item">
                            <a class="nav-link active" href="#model-comparison" data-bs-toggle="pill">
                                <i class="bi bi-bar-chart me-2"></i>模型对比
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#performance-metrics" data-bs-toggle="pill">
                                <i class="bi bi-speedometer2 me-2"></i>性能指标
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#model-deployment" data-bs-toggle="pill">
                                <i class="bi bi-cloud-upload me-2"></i>模型部署
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- 右侧内容 -->
            <div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
                <div class="tab-content">
                    <!-- 模型对比 -->
                    <div class="tab-pane fade show active" id="model-comparison">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">模型对比</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-plus-lg"></i> 添加模型
                            </button>
                        </div>

                        <div class="row">
                            <!-- 性能对比图表 -->
                            <div class="col-md-8">
                                <div class="card mb-4">
                                    <div class="card-body">
                                        <canvas id="modelComparisonChart" height="300"></canvas>
                                    </div>
                                </div>
                            </div>

                            <!-- 模型列表 -->
                            <div class="col-md-4">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">对比模型</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="list-group">
                                            <label class="list-group-item">
                                                <input class="form-check-input me-1" type="checkbox" value="" checked>
                                                LSTM v1.2.0
                                            </label>
                                            <label class="list-group-item">
                                                <input class="form-check-input me-1" type="checkbox" value="" checked>
                                                XGBoost v1.1.0
                                            </label>
                                            <label class="list-group-item">
                                                <input class="form-check-input me-1" type="checkbox" value="">
                                                随机森林 v1.0.0
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 性能指标 -->
                    <div class="tab-pane fade" id="performance-metrics">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">性能指标</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-download"></i> 导出报告
                            </button>
                        </div>

                        <div class="row">
                            <!-- 指标卡片 -->
                            <div class="col-md-3 mb-4">
                                <div class="card metric-card">
                                    <div class="card-body text-center">
                                        <h6 class="card-title">准确率</h6>
                                        <h2 class="text-primary">95.8%</h2>
                                        <small class="text-muted">较上次提升 2.3%</small>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 mb-4">
                                <div class="card metric-card">
                                    <div class="card-body text-center">
                                        <h6 class="card-title">精确率</h6>
                                        <h2 class="text-success">94.2%</h2>
                                        <small class="text-muted">较上次提升 1.5%</small>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 mb-4">
                                <div class="card metric-card">
                                    <div class="card-body text-center">
                                        <h6 class="card-title">召回率</h6>
                                        <h2 class="text-info">93.7%</h2>
                                        <small class="text-muted">较上次提升 1.8%</small>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-3 mb-4">
                                <div class="card metric-card">
                                    <div class="card-body text-center">
                                        <h6 class="card-title">F1分数</h6>
                                        <h2 class="text-warning">93.9%</h2>
                                        <small class="text-muted">较上次提升 1.6%</small>
                                    </div>
                                </div>
                            </div>

                            <!-- 混淆矩阵 -->
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">混淆矩阵</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table table-bordered">
                                                <thead>
                                                    <tr>
                                                        <th></th>
                                                        <th>预测正例</th>
                                                        <th>预测负例</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <th>实际正例</th>
                                                        <td class="text-success">850</td>
                                                        <td class="text-danger">50</td>
                                                    </tr>
                                                    <tr>
                                                        <th>实际负例</th>
                                                        <td class="text-danger">40</td>
                                                        <td class="text-success">860</td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- ROC曲线 -->
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">ROC曲线</h5>
                                    </div>
                                    <div class="card-body">
                                        <canvas id="rocCurveChart" height="300"></canvas>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 模型部署 -->
                    <div class="tab-pane fade" id="model-deployment">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">模型部署</h1>
                            <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#deployModelModal">
                                <i class="bi bi-cloud-upload"></i> 部署模型
                            </button>
                        </div>

                        <div class="row">
                            <!-- 部署状态 -->
                            <div class="col-md-6">
                                <div class="card mb-4">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">部署状态</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                    <tr>
                                                        <th>模型</th>
                                                        <th>环境</th>
                                                        <th>状态</th>
                                                        <th>操作</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td>LSTM v1.2.0</td>
                                                        <td>生产环境</td>
                                                        <td><span class="badge bg-success">运行中</span></td>
                                                        <td>
                                                            <button class="btn btn-sm btn-outline-primary">查看日志</button>
                                                            <button class="btn btn-sm btn-outline-danger">停止</button>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>XGBoost v1.1.0</td>
                                                        <td>测试环境</td>
                                                        <td><span class="badge bg-warning">部署中</span></td>
                                                        <td>
                                                            <button class="btn btn-sm btn-outline-primary">查看进度</button>
                                                            <button class="btn btn-sm btn-outline-danger">取消</button>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <!-- 部署历史 -->
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-header">
                                        <h5 class="card-title mb-0">部署历史</h5>
                                    </div>
                                    <div class="card-body">
                                        <div class="table-responsive">
                                            <table class="table">
                                                <thead>
                                                    <tr>
                                                        <th>时间</th>
                                                        <th>模型</th>
                                                        <th>环境</th>
                                                        <th>状态</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td>2024-03-10 15:30</td>
                                                        <td>LSTM v1.2.0</td>
                                                        <td>生产环境</td>
                                                        <td><span class="badge bg-success">成功</span></td>
                                                    </tr>
                                                    <tr>
                                                        <td>2024-03-10 14:30</td>
                                                        <td>XGBoost v1.1.0</td>
                                                        <td>测试环境</td>
                                                        <td><span class="badge bg-warning">进行中</span></td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 部署模型模态框 -->
    <div class="modal fade" id="deployModelModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">部署模型</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="mb-3">
                            <label class="form-label">选择模型</label>
                            <select class="form-select">
                                <option>LSTM v1.2.0</option>
                                <option>XGBoost v1.1.0</option>
                                <option>随机森林 v1.0.0</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">部署环境</label>
                            <select class="form-select">
                                <option>测试环境</option>
                                <option>生产环境</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">资源配置</label>
                            <div class="input-group">
                                <input type="number" class="form-control" placeholder="CPU核心数" value="2">
                                <input type="number" class="form-control" placeholder="内存(GB)" value="4">
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary">开始部署</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    <script>
        // 模型对比图表
        const comparisonCtx = document.getElementById('modelComparisonChart').getContext('2d');
        new Chart(comparisonCtx, {
            type: 'bar',
            data: {
                labels: ['准确率', '精确率', '召回率', 'F1分数'],
                datasets: [{
                    label: 'LSTM v1.2.0',
                    data: [0.958, 0.942, 0.937, 0.939],
                    backgroundColor: 'rgba(54, 162, 235, 0.5)',
                    borderColor: 'rgba(54, 162, 235, 1)',
                    borderWidth: 1
                }, {
                    label: 'XGBoost v1.1.0',
                    data: [0.945, 0.932, 0.928, 0.930],
                    backgroundColor: 'rgba(255, 99, 132, 0.5)',
                    borderColor: 'rgba(255, 99, 132, 1)',
                    borderWidth: 1
                }]
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: true,
                        max: 1
                    }
                }
            }
        });

        // ROC曲线图表
        const rocCtx = document.getElementById('rocCurveChart').getContext('2d');
        new Chart(rocCtx, {
            type: 'line',
            data: {
                labels: ['0', '0.2', '0.4', '0.6', '0.8', '1.0'],
                datasets: [{
                    label: 'ROC曲线',
                    data: [0, 0.4, 0.7, 0.85, 0.95, 1],
                    borderColor: 'rgba(75, 192, 192, 1)',
                    tension: 0.4,
                    fill: false
                }]
            },
            options: {
                scales: {
                    x: {
                        title: {
                            display: true,
                            text: '假阳性率'
                        }
                    },
                    y: {
                        title: {
                            display: true,
                            text: '真阳性率'
                        }
                    }
                }
            }
        });
    </script>
</body>
</html> 